package com.unknowpupil;

import org.apache.commons.lang3.concurrent.BasicThreadFactory;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * Created at 2020/11/4 by w10g <br>
 * Initialize app ... <br>
 *
 * @author unknowpupil
 * @since 0.0.1
 */
public class App {

    public static void main(String[] args) throws ExecutionException, InterruptedException {
        System.out.println("运行开始");
        ScheduledExecutorService executorService = new ScheduledThreadPoolExecutor(1,
                new BasicThreadFactory.
                        Builder().namingPattern("example-schedule-pool-%d").daemon(true).build());

        ScheduledFuture<String> scheduledFuture = executorService.schedule(new Callable<String>() {
            @Override
            public String call() throws Exception {
                System.out.println(1);
                return "a";
            }
        },10,TimeUnit.SECONDS);

        System.out.println(scheduledFuture.get());


    }
}
